package com.wangxiang.shop.member.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wangxiang.shop.member.dao.MemberDao;
import com.wangxiang.shop.member.entity.MemberEntity;
import com.wangxiang.shop.member.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl extends ServiceImpl<MemberDao,MemberEntity> implements LoginService {
    @Autowired
    private MemberDao memberDao;

    /**
     * 微信登录
     * @param member
     * @return
     */
    @Override
    public MemberEntity wxlogin(MemberEntity member) {
        MemberEntity memberEntity = memberDao.wxLogin(member.getOpenId());
//        System.out.println(member);
        MemberEntity info = new MemberEntity();
        if (memberEntity==null){
            info.setRegisterCode(0);
            info.setOpenId(member.getOpenId());
        }else {
            info.setImage(memberEntity.getImage());
            info.setAge(memberEntity.getAge());
            info.setEmail(memberEntity.getEmail());
            info.setMobail(memberEntity.getMobail());
            info.setName(memberEntity.getName());
            info.setSex(memberEntity.getSex());
            info.setOpenId(memberEntity.getOpenId());
            info.setUserId(memberEntity.getUserId());
            info.setRegisterCode(1);
            info.setInvalidRemark(memberEntity.getInvalidRemark());
            info.setStatus(memberEntity.getStatus());
        }
        return info;
    }
}
